home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / The GIMP / gimp-2.6.8-i686-setup.exe / {app} / lib / gimp / 2.0 / plug-ins / foggify.py < prev    next >
Encoding:
Python Source  |  2009-12-15  |  2.4 KB  |  79 lines

  1. #!/usr/bin/env python
  2.  
  3. #   Gimp-Python - allows the writing of Gimp plugins in Python.
  4. #   Copyright (C) 1997  James Henstridge <james@daa.com.au>
  5. #
  6. #   This program is free software; you can redistribute it and/or modify
  7. #   it under the terms of the GNU General Public License as published by
  8. #   the Free Software Foundation; either version 2 of the License, or
  9. #   (at your option) any later version.
  10. #
  11. #   This program is distributed in the hope that it will be useful,
  12. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #   GNU General Public License for more details.
  15. #
  16. #   You should have received a copy of the GNU General Public License
  17. #   along with this program; if not, write to the Free Software
  18. #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  
  20. from gimpfu import *
  21. import time
  22.  
  23. gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
  24.  
  25. def foggify(img, layer, name, colour, turbulence, opacity):
  26.  
  27.     gimp.context_push()
  28.     img.undo_group_start()
  29.  
  30.     if img.base_type is RGB:
  31.         type = RGBA_IMAGE
  32.     else:
  33.         type = GRAYA_IMAGE
  34.     fog = gimp.Layer(img, name,
  35.                      layer.width, layer.height, type, opacity, NORMAL_MODE)
  36.     fog.fill(TRANSPARENT_FILL)
  37.     img.add_layer(fog, 0)
  38.  
  39.     gimp.set_background(colour)
  40.     pdb.gimp_edit_fill(fog, BACKGROUND_FILL)
  41.  
  42.     # create a layer mask for the new layer
  43.     mask = fog.create_mask(0)
  44.     fog.add_mask(mask)
  45.  
  46.     # add some clouds to the layer
  47.     pdb.plug_in_plasma(img, mask, int(time.time()), turbulence)
  48.  
  49.     # apply the clouds to the layer
  50.     fog.remove_mask(MASK_APPLY)
  51.  
  52.     img.undo_group_end()
  53.     gimp.context_pop()
  54.  
  55. register(
  56.     "python-fu-foggify",
  57.     N_("Add a layer of fog"),
  58.     "Adds a layer of fog to the image.",
  59.     "James Henstridge",
  60.     "James Henstridge",
  61.     "1999,2007",
  62.     N_("_Fog..."),
  63.     "RGB*, GRAY*",
  64.     [
  65.         (PF_IMAGE, "image",       "Input image", None),
  66.         (PF_DRAWABLE, "drawable", "Input drawable", None),
  67.         (PF_STRING, "name",       _("_Layer name"), _("Clouds")),
  68.         (PF_COLOUR, "colour",     _("_Fog color"),  (240, 180, 70)),
  69.         (PF_SLIDER, "turbulence", _("_Turbulence"), 1.0, (0, 10, 0.1)),
  70.         (PF_SLIDER, "opacity",    _("Op_acity"),    100, (0, 100, 1)),
  71.     ],
  72.     [],
  73.     foggify,
  74.     menu="<Image>/Filters/Render/Clouds",
  75.     domain=("gimp20-python", gimp.locale_directory)
  76.     )
  77.  
  78. main()
  79.